"""
:Author: Fernando Pacheco <fernando.pacheco@ingesur.com.uy>
:Date: Sun, 14 Jun 2009 10:22:19 -0300
:copyright: Ingesur SRL
:license: GPL Version 2
:version: 0.10
"""

class HydroGeo(object):
    """
    Base class for hydrogeo library
    
    """
      
    def __init__(self):
        pass

    def equal_intervals_generate(self, inf_lim, sup_lim, n_intervals = 30):
        """
        Equal intervals range generate
        
        :Parameters:
            inf_lim : float
                Inferior limit of the interval
            sup_lim : float
                Superior limit of the interval
            n_intervals : int
                Number of intervals
                                
        :rtype: list of float
        :return: List with values of the range
        
        **Usage**
            >>> from libs.hydrogeo.hydrogeo import HydroGeo
            >>> h = Hydrogeo()            
            >>> print h.equals_intervals_generate(1,10,9)
            [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0]
        """
        uu = []
        if inf_lim >= sup_lim:
            print "Error: Superior limit must be greather than inferior limit"                        
        else:        
            d = (sup_lim - inf_lim)/float(n_intervals)
            for i in range(0, n_intervals+1):
                uu.append( inf_lim + d*i )
        return uu
        
    def log_intervals_generate(self, inf_lim, sup_lim, n_intervals = 30):
        """
        Equal logarithmic intervals range generate
        
        :Parameters:
            inf_lim : float
                Inferior limit of the interval
            sup_lim : float
                Superior limit of the interval
            n_intervals : int
                Number of intervals
                                
        :rtype: list of float
        :return: List with values of the range
        
        **Usage**
            >>> from libs.hydrogeo.hydrogeo import HydroGeo
            >>> h = Hydrogeo()
            >>> i = h.log_intervals_generate(1,10,5)
            >>> print "|".join(str(round(ii,5)) for ii in i if ii > 0)
            '1.0|1.58489|2.51189|3.98107|6.30957|10.0'
        """
        intervals = []
        kk = ( sup_lim/inf_lim )**(1.0/n_intervals)
        for i in range(0, n_intervals+1):
          intervals.append( inf_lim*kk**i )
        return ( intervals )